
(function () {
  // # 交叉类型。它和联合类型的使用位置一样，只不过符号是&，即按位与运算符。
  interface NameStruct {
    name: string;
  }
  interface AgeStruct {
    age: number;
  }
  type ProfileStruct = NameStruct & AgeStruct;


  const profile: ProfileStruct = {
    name: 'lsy',
    age: 15
  }
  // 这里是对于对象类型的合并，那对于原始类型呢？
  type StrAndNum = string & number; // never;

  // 对于对象类型的交叉类型，其内部的同名属性类型同样会按照交叉类型进行合并：
  type Struct1 = {
    primitiveProp: string;
    objectProp: {
      name: string;
    }
  }

  type Struct2 = {
    primitiveProp: number;
    objectProp: {
      age: number;
    }
  }

  type Composed = Struct1 & Struct2;

  type PrimitivePropType = Composed['primitiveProp']; // never
  type ObjectPropType = Composed['objectProp']; // { name: string; age: number; }

  type UnionIntersection1 = (1 | 2 | 3) & (1 | 2);// 1 | 2

  type UnionIntersection2 = (string | number | symbol) & string; // string




}())